package com.module.overview.ui.schedule.provider

import android.os.Bundle
import android.view.View
import com.chad.library.adapter.base.provider.BaseItemProvider
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.common.app.core.RouterHub
import com.common.app.data.bean.KeyBundle
import com.common.app.data.bean.overView.CardSettingModel
import com.common.app.helper.RouterHelper
import com.common.base.app.extras.setSafeOnClickListener
import com.common.base.app.extras.setVisible
import com.common.base.app.extras.startActivity
import com.common.base.utils.ActivityUtils
import com.module.ble.utils.AllCardTypeConfig
import com.module.fitness.utils.ExerciseType
import com.module.overview.R
import com.module.overview.ui.readyCountdown.ReadyCountdownActivity

/**
 *
 * 作者：sosou
 *
 * 版本：1.0
 *
 * 创建日期：2025/6/16
 *
 * 描述：运动卡片
 *
 * 修订历史：完成度100%
 *
 */
class OvMainExerciseCardProvider(
    override val itemViewType: Int = AllCardTypeConfig.TYPE_CARD_EXERCISE,
    override val layoutId: Int = R.layout.overview_main_exercise_crad_provider
) : BaseItemProvider<CardSettingModel>() {


    init {

    }

    override fun convert(helper: BaseViewHolder, item: CardSettingModel) {

        helper.getView<View>(R.id.tvExerciseHint).setSafeOnClickListener {
        }

        helper.getView<View>(R.id.sitOutRunning).setSafeOnClickListener {
            toReadyCountdown(ExerciseType.RUNNING_OUT)
        }
        helper.getView<View>(R.id.sitIndRunning).setSafeOnClickListener {
            toReadyCountdown(ExerciseType.RUNNING_IN)
        }
        helper.getView<View>(R.id.sitOutCycling).setSafeOnClickListener {
            toReadyCountdown(ExerciseType.CYCLING_OUT)
        }
        helper.getView<View>(R.id.sitIndCycling).setSafeOnClickListener {
            toReadyCountdown(ExerciseType.CYCLING_IN)
        }
        helper.getView<View>(R.id.sitIndWalking).setSafeOnClickListener {
            toReadyCountdown(ExerciseType.FITNESS_OUT)
        }
        helper.itemView.setVisible(item.isEnabled)
    }

    override fun onViewHolderCreated(viewHolder: BaseViewHolder, viewType: Int) {
        super.onViewHolderCreated(viewHolder, viewType)
    }

    override fun onViewDetachedFromWindow(holder: BaseViewHolder) {
        super.onViewDetachedFromWindow(holder)
    }

    private fun toReadyCountdown(subType: ExerciseType){
        RouterHelper.navigationPostcard(RouterHub.ROUTER_OVERVIEW_DURING_EXERCISE)
            .withParcelable(KeyBundle.BUNDLE_KEY, subType)
            .navigation()
    }
}